#if defined(CB_PRECOMP)
#include "sdk.h"
#endif

#ifndef CB_PRECOMP
	#include <wx/checkbox.h>
	#include <wx/sizer.h>
#endif

#include "SearchInPanel.h"
#include "ThreadSearchControlIds.h"


SearchInPanel::SearchInPanel(wxWindow* parent, int id, const wxPoint& pos, const wxSize& size, long WXUNUSED(style)):
    wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL) {
   
    m_pChkSearchOpenFiles = new wxCheckBox(this, idChkSearchOpenFiles, wxT("Open files"));
   
    m_pChkSearchSnippetFiles = new wxCheckBox(this, idChkSearchSnippetFiles, wxT("Snippets"));
   
    m_pChkSearchDir = new wxCheckBox(this, idChkSearchDirectoryFiles, wxT("Directory"));

    set_properties();
    do_layout();
   
}


BEGIN_EVENT_TABLE(SearchInPanel, wxPanel)
   
    EVT_CHECKBOX(idChkSearchOpenFiles, SearchInPanel::OnChkClickEvent)
    EVT_CHECKBOX(idChkSearchSnippetFiles, SearchInPanel::OnChkSearchSnippetFilesClick)
   
    EVT_CHECKBOX(idChkSearchDirectoryFiles, SearchInPanel::OnChkClickEvent)
   
END_EVENT_TABLE();


void SearchInPanel::OnChkClickEvent(wxCommandEvent &event) {
    event.Skip();
}


void SearchInPanel::OnChkSearchSnippetFilesClick(wxCommandEvent &event) {


   
   
   
   
   
   
   
	event.Skip();
}


void SearchInPanel::OnChkSearchWorkspaceFilesClick(wxCommandEvent &event) {


	if ( (event.IsChecked()) == true && (m_pChkSearchSnippetFiles->IsChecked() == true) )
	{
		m_pChkSearchSnippetFiles->SetValue(false);
		wxCommandEvent ChkEvent(wxEVT_COMMAND_CHECKBOX_CLICKED, idChkSearchSnippetFiles);
		ChkEvent.SetInt(0);
		ProcessEvent(ChkEvent);
	}
	event.Skip();
}




void SearchInPanel::set_properties() {
   
    m_pChkSearchOpenFiles->SetToolTip(wxT("Search in open files"));
    m_pChkSearchOpenFiles->SetValue(1);
   
    m_pChkSearchSnippetFiles->SetToolTip(wxT("Search in Snippets Tree"));
    m_pChkSearchSnippetFiles->SetValue(1);
   
    m_pChkSearchDir->SetToolTip(wxT("Search in directory files"));
   
}


void SearchInPanel::do_layout() {
#if wxCHECK_VERSION(3, 0, 0)
    #define wxADJUST_MINSIZE 0
#endif
   
    wxBoxSizer* SizerTop = new wxBoxSizer(wxHORIZONTAL);
    SizerTop->Add(m_pChkSearchOpenFiles, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 4);
    SizerTop->Add(m_pChkSearchSnippetFiles, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 4);
   
    SizerTop->Add(m_pChkSearchDir, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxADJUST_MINSIZE, 4);
    SetAutoLayout(true);
    SetSizer(SizerTop);
    SizerTop->Fit(this);
    SizerTop->SetSizeHints(this);
   
}


// Getters
bool SearchInPanel::GetSearchInOpenFiles()      const                       {return m_pChkSearchOpenFiles->IsChecked();}
bool SearchInPanel::GetSearchInSnippetFiles()   const                       {return m_pChkSearchSnippetFiles->IsChecked();}
//-bool SearchInPanel::GetSearchInWorkspaceFiles() const                       {return m_pChkSearchWorkspaceFiles->IsChecked();}
bool SearchInPanel::GetSearchInDirectory()      const                       {return m_pChkSearchDir->IsChecked();}

void SearchInPanel::SetSearchInOpenFiles     (bool bSearchInOpenFiles)      {m_pChkSearchOpenFiles->SetValue(bSearchInOpenFiles);}

void SearchInPanel::SetSearchInSnippetFiles  (bool bSearchInSnippetFiles)   {m_pChkSearchSnippetFiles->SetValue(bSearchInSnippetFiles);}

void SearchInPanel::SetSearchInDirectory     (bool bSearchInDirectory)      {m_pChkSearchDir->SetValue(bSearchInDirectory);}
